home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_3.zip / FILEMGR.CMD < prev    next >
OS/2 REXX Batch file  |  1992-03-23  |  24KB  |  839 lines

  1.    SET TTHRU OFF        ; Make first to allow typeahead
  2.    S15 = "INTERNAL"             ; Set your word processor name here
  3. ;                ; .. "INTERNAL" -> Use COM-AND's internal editor
  4. ; ----- FileMgr: File manager shell for COM-AND
  5. ;
  6. ;    R.McG;     7/89, Chicago
  7. ;    updated: 3/92 (to use COM-AND's internal editor)
  8. ; ----------------------------------------------------------------
  9. ;    Note: You should change the second line above to specify the
  10. ;    name of the word processor you typically use.  When invoked
  11. ;    the file name to be edited is appended to the program name,
  12. ;    (e.g. equivalend to "d> PE file.txt").  If this is not appro-
  13. ;    priate, you must change the logic at the end of this script.
  14. ; ----------------------------------------------------------------
  15. ; Usages:
  16. ;    S19 -----> Legend line
  17. ;    S18 -----> Load-time drive:subdirectory (for exit)
  18. ;    S17 -----> Load-time download d:subdir (for exit)
  19. ;    S16 -----> Current file mask (for DIR function)
  20. ;    S15 -----> Editor or wordprocessor program file name
  21. ;
  22. ;    N99 -----> Number of lines on screen
  23. ;    N92 -----> Current cursor
  24. ;    N91 -----> Current cursor
  25. ;    N90 -----> Current screen highlight (1 to N99-6)
  26. ;
  27. ;    FLAG(2) -> Off if we are on left side of the display
  28. ; -----------------------------------------------------------------------
  29. ;
  30. ;    Initialization
  31. ;
  32.    CURSOR N91,N92        ; Read current cursor
  33.    S19 = "FileMgr ver 1.0     " ; 20 chars long
  34.    LEGEND S19            ; Set initial legend
  35.    SUBDIR S18            ; Read current subdir
  36.    DLDIR S17            ; Read current download subdir
  37.    SSIZE N99            ; get current screen size
  38.    SAVE 0,0,N99-2,79        ; Save original screen
  39.    ON ESCAPE GOSUB ESCAPE    ; Escape action
  40.    S16 = "*.*"                  ; Set default mask
  41. ;
  42. ;    Ask for a directory change, and then start
  43. ;
  44.    GOSUB Ask_Dir        ; Ask for a directory change
  45.    GOTO START            ; And continue
  46. ;
  47. ;    Escape - Clear all windows, and exit
  48. ;
  49. Escape:
  50.    SET DLDIR S17        ; Reset DLDIR  to load time
  51.    CHDIR S18            ; Reset default subdir to load time
  52.    RESTORE            ; Restore screen
  53.    LOCATE N91,N92        ; Restore cursor
  54.    EXIT             ; End script
  55. ;
  56. ;    Draw the screen, and decide if we're linked
  57. ;
  58. Start:
  59.    GOSUB Screen         ; Draw screen
  60.    GOSUB DispFirst        ; Build our directory list
  61.    N90 = 1            ; Set initial cursor
  62.    SET FLAG(2) OFF        ; On Left of display
  63.    GOSUB Set_Cursor        ; Set 1st cursor
  64. ;
  65. ;    We have a keypress pending
  66. ;
  67. Main:
  68.    KEYGET S1            ; Read a single key
  69.    SWITCH S1
  70.       CASE "4D00"               ; Cursor_Right
  71.      GOSUB Change_Sides
  72.       ENDCASE
  73.       CASE "4B00"               ; Cursor left
  74.      GOSUB Change_Sides
  75.       ENDCASE
  76.       CASE "4900"               ; PgUp
  77.      GOSUB Prev_Page
  78.       ENDCASE
  79.       CASE "5100"               ; PgDn
  80.      GOSUB Next_Page
  81.       ENDCASE
  82.       CASE "4700"               ; Home
  83.      GOSUB Home_Page
  84.       ENDCASE
  85.       CASE "4F00"               ; End
  86.      GOSUB End_Page
  87.       ENDCASE
  88.       CASE "4800"               ; Cursor Up
  89.      GOSUB Cursor_Up
  90.       ENDCASE
  91.       CASE "5000"               ; Cursor down
  92.      GOSUB Cursor_Down
  93.       ENDCASE
  94.       CASE "7100"               ; Alt-F10
  95.      SHELL
  96.       ENDCASE
  97.       CASE "5200"               ; INS key
  98.      GOSUB DOS
  99.       ENDCASE
  100.  
  101.       CASE "N"                  ; Change directory
  102.      GOSUB NewDir
  103.       ENDCASE
  104.       CASE "U"                  ; Upload a file
  105.      GOSUB Upld
  106.       ENDCASE
  107.       CASE "H"                  ; Help
  108.      GOSUB Help
  109.       ENDCASE
  110.       CASE "S"                  ; Send
  111.      GOSUB Send
  112.       ENDCASE
  113.       CASE "F"                  ; Free space
  114.      GOSUB Free
  115.       ENDCASE
  116.       CASE "V"                  ; View a file
  117.      GOSUB View
  118.       ENDCASE
  119.       CASE "W"                  ; Wordprocessor
  120.      GOSUB Word
  121.       ENDCASE
  122.       CASE "E"                  ; Execute a program
  123.      GOSUB EXEC
  124.       ENDCASE
  125.       CASE "C"                  ; Copy a file
  126.      GOSUB Copy
  127.       ENDCASE
  128.       CASE "D"                  ; Delete a file
  129.      GOSUB Delete
  130.       ENDCASE
  131.       CASE "R"                  ; Rename
  132.      GOSUB Rename
  133.       ENDCASE
  134.       CASE "M"                  ; New mask
  135.      GOSUB Mask
  136.       ENDCASE
  137.  
  138.       DEFAULT
  139.     SOUND 100,100        ; Signal displeasure
  140.       ENDCASE
  141.    ENDSWITCH
  142.    GOTO Main            ; And continue
  143. ;
  144. ; ----- Subroutine: Read the line at the current highlight
  145. ;    .. according to the current seting of FLAG(2)
  146. ;    S12 returns the line at the current cursor
  147. ;
  148. Read_Cursor:
  149.     S12 = ""
  150.     IF NOT ZERO N90
  151.        IF FLAG(2)        ; IF true we're on Remote
  152.           ATSCR N90,41,37 S12
  153.        ELSE
  154.           ATSCR N90, 2,37 S12
  155.           ENDIF
  156.        ENDIF
  157.     RETURN
  158. ;
  159. ; ----- Subroutine: Clear the current highlight
  160. ;    .. according to the current setting of FLAG(2)
  161. ;
  162. Clear_Cursor:
  163.     IF NOT ZERO N90
  164.        GOSUB Read_Cursor
  165.        IF FLAG(2)        ; IF true we're on remote
  166.           ATSAY N90,41 (default) S12
  167.        ELSE
  168.           ATSAY N90, 2 (default) S12
  169.           ENDIF
  170.        ENDIF
  171.     RETURN
  172. ;
  173. ; ----- Subroutine: Display the current highlight
  174. ;    .. according to the current stting of FLAG(2)
  175. ;
  176. Set_Cursor:
  177.     GOSUB Read_Cursor
  178.     IF NOT ZERO N90
  179.        IF FLAG(2)        ; IF true we're on remote
  180.           IF NOT NULL S12
  181.          ATSAY N90,41 (contrast) S12
  182.           ELSE
  183.          N90 = N90-1
  184.          GOTO Set_Cursor
  185.          ENDIF
  186.        ELSE         ; On own side
  187.           IF NOT NULL S12
  188.          ATSAY N90, 2 (contrast) S12
  189.           ELSE
  190.          N90 = N90-1
  191.          GOTO Set_Cursor
  192.          ENDIF
  193.           ENDIF
  194.        ENDIF
  195.     RETURN
  196. ;
  197. ; ----- Subroutine: Move the cursor Up
  198. ;
  199. Cursor_Up:
  200.     GOSUB Clear_Cursor
  201.     IF GT N90 1
  202.        N90 = N90-1
  203.     ELSE
  204.        N90 = N99-6
  205.        ENDIF
  206.     GOSUB Set_Cursor
  207.     RETURN
  208. ;
  209. ; ----- Subroutine: Move the cursor Down
  210. ;
  211. Cursor_Down:
  212.     GOSUB Clear_Cursor
  213.     IF LT N90 (N99-6)
  214.        N90 = N90+1
  215.     ELSE
  216.        N90 = 1
  217.        ENDIF
  218.     GOSUB Set_Cursor
  219.     RETURN
  220. ;
  221. ; ----- Subroutine: Change the display side
  222. ;
  223. Change_Sides:
  224.     GOSUB Clear_Cursor    ; Clear cursor if any
  225.     IF FLAG(2)        ; IF true we're on right
  226.        SET FLAG(2) OFF    ; .. make it left
  227.     ELSE            ; etc
  228.        SET FLAG(2) ON
  229.        ENDIF
  230.     GOSUB Set_Cursor    ; And renew cursor
  231.     RETURN
  232. ;
  233. ; ----- Subroutine: Clear a window - right or left
  234. ;    .. according to the current stting of FLAG(2)
  235. ;
  236. Clear_Window:
  237.     IF FLAG(2)        ; IF true we're on remote
  238.        SCROLL 0,1,40,(N99-6),77 (default)
  239.     ELSE
  240.        SCROLL 0,1,1,(N99-6),38 (default)
  241.        ENDIF
  242.     N90 = 0         ; Clear current cursor
  243.     RETURN
  244. ;
  245. ; ----- Subroutine: Display the previous page
  246. ;
  247. Prev_Page:
  248.     SOUND 55,500        ; Unimplemented
  249.     RETURN
  250. ;
  251. ; ----- Subroutine:  Display the next page
  252. ;
  253. Next_Page:
  254.     GOSUB DispNext        ; Display next page
  255.     N90 = 1         ; Set initial cursor
  256.     SET FLAG(2) OFF     ; On Left of display
  257.     GOSUB Set_Cursor    ; And reset cursor
  258.     RETURN
  259. ;
  260. ; ----- Subroutine:  Set to the home page
  261. ;
  262. Home_Page:
  263.     GOSUB DispFirst     ; Display first page
  264.     N90 = 1         ; Set initial cursor
  265.     SET FLAG(2) OFF     ; On Left of display
  266.     GOSUB Set_Cursor    ; And reset cursor
  267.     RETURN
  268. ;
  269. ; ----- Subroutine:  Find the ending page
  270. ;
  271. End_Page:
  272.     SOUND 55,500        ; Unimplemented
  273.     RETURN
  274. ;
  275. ; ----- Subroutine: Display first page of directory
  276. ;
  277. DispFirst:
  278.    FFIRST S16           ; Initialize
  279.    IF Failure           ; If not found
  280.       RETURN           ; Quit here
  281.       ENDIF
  282. ;
  283. ; ----- Subroutine: Display directory using current position
  284. ;    Note: Cursor is repositioned to top left
  285. ;
  286. DispNext:
  287.    N90 =  1           ; Clear current cursor
  288.    SET FLAG(2) ON       ; Clear right side
  289.    GOSUB Clear_Window       ; ..
  290.    SET FLAG(2) OFF       ; Clear left side
  291.    GOSUB Clear_Window       ; ..
  292.  
  293.    N1 = 1           ; Set loop counter
  294. ;
  295. ;    Read and display the file names
  296. ;
  297. DINE100:
  298.    FNEXT S1           ; Get next file name
  299.    IF Failure           ; If end of list
  300.       IF LE N1 1       ; If empty screen
  301.      GOTO DispFirst    ; Restart
  302.      ENDIF
  303.       RETURN           ; Else, quit
  304.       ENDIF
  305. ;
  306. ;    Skip subdirectory files
  307. ;
  308.    IF STRCMP S1(1:1) "."   ; Skip parent subdir
  309.       GOTO DINE100       ; SKip this file
  310.       ENDIF
  311. ;
  312. ;    Skip subdirectories
  313. ;
  314.    FATTR S2 S1           ; Get attribute
  315.    IF STRCMP S2(3:3) "1"   ; If a subdirectory
  316.       GOTO DINE100       ; Goto endloop
  317.       ENDIF
  318. ;
  319. ;    Get remaining information and build the display line
  320. ;
  321.    FSIZE S2 S1           ; Get file size
  322.    FDATE S3 S1           ; Get file date
  323.    FTIME